package com.icinfo.cloud.provider.punish.api.controller;

import com.icinfo.cloud.common.core.page.PageResponse;
import com.icinfo.cloud.provider.punish.api.dto.CaseBaseInfoResponse;
import com.icinfo.cloud.provider.punish.api.dto.CaseTransferPageRequest;
import com.icinfo.cloud.provider.punish.api.dto.CaseTransferPageResponse;
import com.icinfo.cloud.provider.punish.api.service.ICaseTransferApiService;
import com.icinfo.cloud.provider.punish.ucase.investigateevidence.transfer.dto.CaseTransferIdTypeDto;
import com.icinfo.cloud.provider.punish.ucase.investigateevidence.transfer.dto.CaseTransferRecordDto;
import com.icinfo.cloud.provider.punish.ucase.investigateevidence.transfer.service.ICaseTransferRecordService;
import com.icinfo.cloud.provider.punish.ucase.investigateevidence.transfer.vo.CaseInitiateInfoVo;
import com.icinfo.framework.common.web.Result;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.List;

/**
 * 描述：案件移送api(两法服务调用)
 *
 * @Author zhengqiang
 * @Date 2022/9/21 17:37
 **/
@RestController
@RequestMapping("/punish/api/transfer")
public class CaseTransferApiController {

    @Resource
    private ICaseTransferApiService caseTransferApiService;
    @Resource
    private ICaseTransferRecordService caseTransferRecordService;


    /**
     * 描述： 查询移送案件详情
     *
     * @return {@link Result< CaseBaseInfoResponse>}
     * @author: zhengqiang
     * @date: 2022/9/26
     * @param: caseBaseId
     **/
    @GetMapping(value = "/getTransferCaseBaseDetail")
    Result<CaseBaseInfoResponse> getTransferCaseBaseDetail(@RequestParam("caseId") String caseId) {
        CaseBaseInfoResponse caseBaseInfoResponse = caseTransferApiService.getTransferCaseBaseDetail(caseId);
        return Result.success("查询成功!", caseBaseInfoResponse);
    }

    /**
     * 描述： 办案协同-统一两法衔接查询-我的移送
     *
     * @author: yehuafei
     * @date: 2022/11/29
     * @param: CaseTransferPageRequest
     * @return {@link Result< PageResponse>}
     **/
    @PostMapping(value = "/getCaseTransferPage")
    public Result<PageResponse> getCaseTransferPage(@RequestBody CaseTransferPageRequest request) {
        List<CaseTransferPageResponse> list = caseTransferApiService.getCaseTransferList(request);
        return Result.success("查询成功!", new PageResponse(list));
    }
    /**
     * 修改案件移交记录
     *
     * @param caseTransferRecordDto 案件移交记录入参对象
     * @return com.icinfo.framework.common.web.Result<java.lang.String>
     * @author liuyongfei
     * @date 2022/12/08
     */
    @PostMapping(value = "/updateCaseTransferRecord")
    public Result<String> updateCaseTransferRecord(@RequestBody @Validated CaseTransferRecordDto caseTransferRecordDto) {
        return caseTransferRecordService.updateCaseTransferRecord(caseTransferRecordDto);
    }

    /**
     * 新增案件移交记录
     *
     * @param caseTransferRecordDto 案件移交记录入参对象
     * @return com.icinfo.framework.common.web.Result<java.lang.String>
     * @author liuyongfei
     * @date 2022/12/08
     */
    @PostMapping(value = "/saveCaseTransferRecord")
    public Result<String> saveCaseTransferRecord(@RequestBody @Validated CaseTransferRecordDto caseTransferRecordDto) {
        return caseTransferRecordService.saveCaseTransferRecord(caseTransferRecordDto);
    }

    /**
     * 删除案件移交记录
     *
     * @param caseTransferIdTypeDto 案件移交删除参数对象
     * @return com.icinfo.framework.common.web.Result<java.lang.String>
     * @author liuyongfei
     * @date 2022/12/09
     */
    @PostMapping(value = "/deleteCaseTransferRecord")
    public Result<String> deleteCaseTransferRecordByCaseId(@RequestBody @Validated CaseTransferIdTypeDto caseTransferIdTypeDto) {
        return caseTransferRecordService.deleteCaseTransferRecord(caseTransferIdTypeDto);
    }

    /**
     * 查询案件移交发起信息
     *
     * @param caseTransferIdTypeDto 案件/案源移交查询参数对象
     * @return com.icinfo.framework.common.web.Result<com.icinfo.cloud.provider.punish.ucase.investigateevidence.transfer.vo.CaseInfoVo>
     * @author liuyongfei
     * @date 2022/12/09
     */
    @PostMapping(value = "/getInitiateInfo")
    public Result<CaseInitiateInfoVo> getInitiateInfo(@RequestBody @Validated CaseTransferIdTypeDto caseTransferIdTypeDto) {
        return caseTransferRecordService.getInitiateInfo(caseTransferIdTypeDto);
    }
}
